package com.lianqi.emcpframework.data.masker;
import com.lianqi.emcpframework.data.masker.stratgey.DataMaskStrategy;

import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * @program emcp-framework
 * @ClassName MaskerDefinition
 * @description: 数据遮罩定义
 * @author: sky
 * @create: 2019/05/25 18:32
 */
public interface MaskerDefinition<T> {

    default Class<?> supportType(){
        ParameterizedType type = (ParameterizedType)this.getClass().getGenericInterfaces()[0];
        return (Class<?>) type.getActualTypeArguments()[0];
    }

    boolean support(Field field);

    T maskValue(Field field,Object source);

    DataMaskStrategy getStrategy(MaskFieldType type);

    void addDataMaskStrategy(MaskFieldType type, DataMaskStrategy<T> strategy);
}
